package com.jiangxjsy.admin.controller;

import com.jiangxjsy.admin.service.AdminDeptService;
import com.jiangxjsy.core.wrap.Result;
import com.jiangxjsy.core.wrap.ResultBuilder;
import com.jiangxjsy.model.admin.bo.AdminDeptBO;
import com.jiangxjsy.model.admin.bo.AdminDeptQueryBO;
import com.jiangxjsy.model.admin.vo.AdminDeptVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/6 16:31
 */

@RestController
@RequestMapping("/adminDept")
public class AdminDeptController {
    @Resource
    private AdminDeptService adminDeptService;

    /**
     * 查询部门列表树
     *
     * @param queryBO 查询参数
     * @return 部门列表树
     */
    @PostMapping("/queryDeptTree")
    public Result<List<AdminDeptVO>> queryDeptTree(@RequestBody AdminDeptQueryBO queryBO) {
        List<AdminDeptVO> deptList = adminDeptService.queryDeptTree(queryBO);
        return ResultBuilder.ok(deptList);
    }

    /**
     * 新增部门
     *
     * @param adminDept 部门信息
     * @return 新增结果
     */
    @PostMapping("/addDept")
    public Result<?> addDept(@RequestBody AdminDeptBO adminDept) {
        adminDeptService.addDept(adminDept);
        return ResultBuilder.ok();
    }
}
